Skip to content

Recommend Never for return types as well - #2322

Merged
srittau merged 1 commit into
python:mainfrom
srittau:no-return
Jul 22, 2026
Merged

Recommend Never for return types as well#2322
srittau merged 1 commit into
python:mainfrom
srittau:no-return

Conversation

@srittau

@srittau srittau commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

Per discussion in python/cpython#132941

@srittau
srittau merged commit 39164cd into python:main Jul 22, 2026
5 checks passed
@srittau
srittau deleted the no-return branch July 22, 2026 14:30
@ngnpope

ngnpope commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

This change updated this section, but there are other places that should probably also be reworded:

https://typing.python.org/en/latest/spec/special-types.html#never has the following:

The Never type is equivalent to NoReturn, which is discussed above. The NoReturn type is conventionally used in return annotations of functions, and Never is typically used in other locations, but the two types are completely interchangeable.

https://typing.python.org/en/latest/spec/special-types.html#noreturn should probably also say that Never is preferred.

https://typing.python.org/en/latest/spec/constructors.html has some references to NoReturn that could be changed to Never?

On the https://typing.python.org/en/latest/spec/special-types.html page, perhaps Never should come above NoReturn and the examples for NoReturn should be moved to Never, with NoReturn being a simple statement saying that Never is preferred?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants